package com.mmall.controller.portal;


import com.github.pagehelper.PageInfo;
import com.mmall.common.ServerResponse;
import com.mmall.service.IProductService;
import com.mmall.vo.ProductDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/product/")
public class ProductController {

    @Autowired
    private IProductService iProductService;


    /**
     * 前端商品详情,根据详情的id查询
     * @param productId
     * @return
     */
    @RequestMapping(value = "Detail.do")
    @ResponseBody
    public ServerResponse<ProductDetailVo> Detail(Integer productId){

        return  iProductService.Detail(productId);
    }

    @RequestMapping(value = "List.do")
    @ResponseBody
    public  ServerResponse<PageInfo> List( @RequestParam(value = "pageName",defaultValue = "1") Integer pageName,
                                           @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
                                           @RequestParam(value = "pageName",required = false) String productName,
                                           @RequestParam(value = "categoryId",required = false)Integer categoryId,
                                           @RequestParam(value = "orderBy", defaultValue = "")String orderBy){

        return  iProductService.List(orderBy,pageName,pageSize,productName,categoryId);
    }

}
